package com.web.shop.controller;


import com.web.shop.document.EsItem;
import com.web.shop.service.EsItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin("*")
public class EsItemController {
    @Autowired
    private EsItemService esItemService;
    @GetMapping("/queryItemByPrefixkeyword")
    public List<EsItem> queryItemByPrefixkeyword(String keyword)
    {
        System.out.println("111111111111111111");
        System.out.println("查询关键词为："+keyword);
       Page<EsItem> page =esItemService.queryEsItem(keyword,null);
        System.out.println("2222222222222222222");
        System.out.println("查询记录为："+page.getContent().toString());
       return page.getContent();
    }
    @GetMapping("/queryItemDetails")
    public EsItem queryItemDetails(Long goods_id)
    {
            return esItemService.findEsItemById(goods_id);
    }

}
